{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
    <h3 class="pb-3">添加信息</h3>
    {if condition="($id == 0)"}

    {else/}
    <table class="layui-table layui-table-form" id="fenpei_box">
        <tr>
            <td colspan="6"><strong>公司信息</strong></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">公司名称</td>
            <td>{$detail.license_name}</td>
            <td class="layui-td-gray-2">合同编号</td>
            <td>{$detail.contract_no}</td>
        </tr>
        <tr>
            <td colspan="6"><strong>所需信息</strong></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">所需人数</td>
            <td>{$detail.bitjob_number}</td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">所需人员类型</td>
            <td>{$detail.bitjob_type}

            <td class="layui-td-gray-2">所需证书类型</td>
            <td>{$detail.cert_major_type}</td>
        </tr>
        <tr>
            <td colspan="6"><strong>分配信息</strong></td>
        </tr>
    </table>

        <div>
            <input type="text"  value="添加人才+"
                   class="layui-input bitjob-picker">
        </div>

    {/if}
    <div class="py-3">
        <input name="id" id="id" type="hidden" value="{$id}">
        <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
    </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool', 'employeepicker', 'oaTool'];
    function gouguInit() {
        var form = layui.form, tool = layui.tool, table = layui.table, laydate = layui.laydate, oaTool = layui.oaTool,
            employeepicker = layui.employeepicker;
        laydate.render({
            elem: '#reg_date',
            showBottom: false
        });

        laydate.render({
            elem: '#reg_valid_date',
            showBottom: false
        });

        //相关附件上传
        oaTool.addFile();
        $('.del-cert').on('click', function () {
            $(this).parent().siblings().remove();
            $(this).parent().remove();
            $(this).remove();
        });
        //选择关联的人才
        $('.bitjob-picker').on('click', function () {
            let that = $(this);
            let callback = function (data) {
            var fenpei_box = '<tr>';
                fenpei_box+='<td class="layui-td-gray-2">姓名</td>';
                fenpei_box+='<td>'+data.salesman_name+'</td>';
                fenpei_box+='<td class="layui-td-gray-2">证书类型</td>';
                fenpei_box+='<td>'+data.cert_major_type+'</td>';
                fenpei_box+='<td class="layui-td-gray-2">人员类型</td>';
                fenpei_box+='<td>'+data.type_name+'</td>';
                fenpei_box+='<td class="layui-td-gray-2">收证金额</td>';
                fenpei_box+='<td>'+data.money+'</td>';
                fenpei_box+='<input name="names[]"  type="hidden" value="'+data.salesman_name+'" class="layui-input">';
                fenpei_box+='<input name="moneys[]"  type="hidden" value="'+data.money+'" class="layui-input">';
                fenpei_box+='<input name="type_names[]"  type="hidden" value="'+data.type_name+'" class="layui-input">';
                fenpei_box+='<input name="cert_major_types[]"  type="hidden" value="'+data.cert_major_type+'" class="layui-input">';
                fenpei_box+='<td class="layui-td-gray-2">出证时金额</td>';
                fenpei_box+='<td><input name="new_moneys[]"  type="text" value="" class="layui-input"></td>';
                fenpei_box+='<td class="layui-td-gray-2">说明</td>';
                fenpei_box+='<td><input name="descs[]"  type="text" value="" class="layui-input"></td>';
                fenpei_box+='<input name="bitjob_ids[]"  type="hidden" value="'+data.id+'">';

                fenpei_box+='<td class="layui-inline">';
                fenpei_box+='<input type="button" value="删除+" class="layui-input del-cert">';
                fenpei_box+='</tr>';

                $("#fenpei_box").append(fenpei_box);
                $('.del-cert').on('click', function () {
                    $(this).parent().siblings().remove();
                    $(this).parent().remove();
                    $(this).remove();
                });
            }
            oaTool.bitjobPicker(callback);
        });
        //radio选择
        form.on('radio(tax)', function (data) {
            if (data.value == 0) {
                $('[name="tax"]').val('0').hide();
            } else {
                $('[name="tax"]').val('').show();
            }
        });

        //监听提交
        form.on('submit(webform)', function (data) {

            let callback = function (e) {
                layer.msg(e.msg);
                if (e.code == 0) {
                    tool.sideClose(1000);
                }
            }
            tool.post("/bitjob/Enterpriseouter/fenpei_add", data.field, callback);
            return false;
        });
    }
</script>
{/block}
<!-- /脚本 -->